package com.code.day08;

//冒泡排序

import java.lang.reflect.Array;
import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {
        int[] arr = {5, 3, 2, 1, 4};
        for (int j = 0; j < arr.length-1; j++) {
            System.out.println("第"+j+"次"+Arrays.toString( arr));
            for (int i = 0; i < arr.length-1-j; i++) {
                if (arr[i] > arr[i+1]){
                    int temp = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = temp;
                }

            }
        }


        System.out.println(Arrays.toString( arr));
    }
}
